package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.pojo.Emp;
import com.itheima.pojo.EmpQueryParam;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

/**
 * 员工持久层
 */
@Mapper
public interface EmpMapper {
    // 查询所有员工以及部门的名称
   // @Select("select e.*,d.name dept_name from emp e left join dept d on e.dept_id = d.id where d.name like concat('%',#{name},'%') and e.gender=#{gender} and e.entry_date between #{begin} and #{end}")
   // Page<Emp> list(String name, Integer gender, LocalDate begin, LocalDate end);
    Page<Emp> list(EmpQueryParam empQueryParam);
//    @Options(useGeneratedKeys = true,keyProperty = "id")
//    @Insert("insert into emp(username,password,name,gender,phone,job,salary,image,entry_date,dept_id,create_time,update_time) values(#{username},#{password},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    void insert(Emp emp);
     //  批量删除员工信息

    void deleteByIds(List<Integer> ids);
   //  查询员工信息和员工经历信息

    Emp getInfo(Integer id);
   //  更新员工信息
    void updateById(Emp emp);

    Long getCountByDeptId(Integer id);
   //  查询员工信息
    @MapKey("pos")
    List<Map<String, Object>> empJobData();
    @MapKey("name")
    List<Map<String, Object>> empGenderData();
}
